<div class="main-content">
    <div class="section__content section__content--p20">
        <div class="container-fluid">
            <div class="row m-b-30">
                <div class="col-lg-12">
                    <div class="overview-wrap">
                        <h2 class="title-1">友情链接</h2>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="table-responsive table--no-card m-b-30">
                        <table class="table table-borderless table-striped table-earning">
                            <thead>
                            <tr>
                                <th>网站名称</th>
                                <th>地址</th>
                                <th>Logo地址</th>
                                <th>关键字</th>
                                <th>排序</th>
                                <th>已审核</th>
                                <th>已读</th>
                                <th>类型</th>
                                <th>工具</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            if (sizeof($friendlinks) > 0) {
                                foreach ($friendlinks as $f) {
                                    ?>
                                    <tr>
                                        <td><?php echo $f['webname']; ?></td>
                                        <td><?php echo $f['weburl']; ?></td>
                                        <td><?php echo $f['logourl']; ?></td>
                                        <td><?php echo $f['keyword']; ?></td>
                                        <td><?php echo $f['seq']; ?></td>
                                        <td><?php echo $f['isauth'] == 0 ? "<span class='red'>否</span>" : "是"; ?></td>
                                        <td>
                                            <?php echo $f['haveread'] == 0 ? "<span class='red'>否</span>" : "是"; ?>
                                        </td>
                                        <td><?php echo $f['linktype'] == 1 ? "文字" : "图片"; ?></td>
                                        <td>
                                            <button type="button" class="btn btn-primary btn-sm"
                                                    onclick="showedit(<?php echo $f['friendlink_id']; ?>)">编辑</button>
                                            <button type="button"  data-toggle="modal" data-target="#confirmModal"  class="btn btn-danger btn-sm" onclick="del(<?php echo $f['friendlink_id']; ?>)">删除</button>
                                        </td>
                                    </tr>
                                    <?php
                                }
                            }
                            ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function showedit(id) {
        window.location.href  = "index.php?r=admin/friendlink/showedit&id=" + id;
    }
    function del(id) {
        $("#confirmModal_text").text('是否删除该友情链接？');
        $("#confirmModalButton").bind("click",function () {
            $.get('index.php?r=admin/friendlink/del&id=' + id, null, function (result) {
                if(message(result)){
                    window.location.href = "index.php?r=admin/friendlink/index";
                }
            }, 'json');
        });
    }
</script>